//
//  main.m
//  08-iOS9新特性及类的扩展
//
//  Created by LL.F on 16/7/13.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Animal.h"
#import "Dog.h"
#import "NSMutableArray+Sort.h"

int main(int argc, const char * argv[]) {
    
    // 1.iOS9新特性三块的深入理解, 创建几个类, 熟悉写法(提交练习成果)
    // 2.iOS 类扩展方式的复习 1> 给NSMutableArray添加convert方法，实现数组倒序。
    // 3.预习UI内容
    
    // 1.nullability
    // <1> nonnull
    Animal *animal1 = [[Animal alloc] init];
    animal1.kind = nil;
    //[animal1 setKind:<#(NSString * _Nonnull)#>];
    [animal1 kind];
    // <2> nullable
    animal1.color = nil;
    //[animal1 setColor:<#(NSString * _Nullable)#>];
    [animal1 color];
    // <3> null_resettable
    animal1.name = nil;
    //[animal1 setName:<#(NSString * _Nullable)#>];
    [animal1 name];
    
    // 2.泛型
    // <1> 数组
    NSMutableArray *mutaleArray1 = [NSMutableArray arrayWithObjects:@13, nil];
    //[mutaleArray addObject:<#(nonnull id)#>];
    NSMutableArray<NSString *> *mutaleArray2 = [NSMutableArray arrayWithObjects:@89, [NSNumber numberWithInt:45], nil];
    //[mutaleArray2 addObject:<#(nonnull NSString *)#>];
    // <2> 字典
    NSMutableDictionary *mutableDic1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"lihua", @"name", nil];
    //[mutableDic1 setObject:<#(nonnull id)#> forKey:<#(nonnull id<NSCopying>)#>];
    NSMutableDictionary<NSString *, NSString *> *mutableDic2 = [NSMutableDictionary dictionary];
    //[mutableDic2 setObject:<#(nonnull NSString *)#> forKey:<#(nonnull id<NSCopying>)#>];
    // <3> 自定义泛型
    Dog *dog = [[Dog alloc] init];
    //[dog setGender:<#(id)#>];
    Dog<Animal *> *dogAnimal = [[Dog alloc] init];
    //[dogAnimal addObject:<#(Animal *)#>];
    [dogAnimal anyObject];
    [dogAnimal addObject:mutableDic2];//类型不对
    // <4> 协变与逆变
    Dog<NSArray *> *superDog = nil;
    Dog<NSMutableArray *> *subDog = nil;
    superDog = subDog;
    subDog = superDog;//__covariant变成__contravariant实现强转
    
    //__kindof
    Dog *DicDog= [[Dog alloc] init];
    NSMutableDictionary *dic = (NSMutableDictionary *)[DicDog returnDictionary];
    NSMutableDictionary *kinfofDic = [DicDog returnDictionary];
    
    //2.
    NSMutableArray *sortArray = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", nil];
    [sortArray convert];
    
    
    
    
    return 0;
}
